<!-- 文档管理 -->
<template>
  <div>
    <contextmenu :itemList="menuItemList" :visible.sync="menuVisible" style="z-index: 9999;" @select="onMenuSelect"/>
    <a-row>
      <a-col :span="6">
        <a-card  style="height: 100vh;overflow-y:scroll; padding: 0" :bordered="false">
          <div style="border-bottom: 1px solid #ccc; width: 100%;">
            <a-button type="link" icon="folder-add" size="large" @click="handleRootCreate('create')">创建根目录</a-button>
          </div>
          <a-tree
            v-if="treeDataSource && treeDataSource.length"
            blockNode
            default-expand-all
            showIcon
            checkStrictly
            :selectedKeys="selectedKeys"
            :dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
            :treeData="treeDataSource"
            :autoExpandParent="true"
            @select="handleTreeSelect"
            @expand="handleTreeExpand"
            @rightClick="onContextmenu($event, 'folder', 'tree')"
            :replaceFields="{children:'data', title:'value', key:'id' }"
          >
          </a-tree>
        </a-card>
      </a-col>
      <a-col :span="18">
        <a-card :bordered="false" style="min-height: 100vh">
          <a-row type="flex" justify="space-between">
            <a-col :span="12">
              <a-row>
                <a-col :span="24">
                  <a-breadcrumb separator=">">
                    <a-breadcrumb-item v-for="(item, index) in breadcrumbList" :key="item.id" href @click.native="handleBread(item, index)">{{item.value}}</a-breadcrumb-item>
                  </a-breadcrumb>
                </a-col>
              </a-row>
            </a-col>
            <a-col :span="8">
              <a-row type="flex" justify="end" align="middle">
                <a-col :span="18">
                  <a-input-search placeholder="搜索文件名" v-model="keyWord" />
                </a-col>
                <a-col :span="4">
                  <a-button type="link" icon="download" size="large" @click="handleDownLoad()" :loading="downLoadLoading">下载</a-button>
                </a-col>
                <!-- <a-col :span="4">
                  <a-button type="link" icon="edit" size="large"  @click="handleEdit()">修改</a-button>  
                </a-col>
                <a-col :span="4">
                  <a-button type="link" icon="delete" size="large">删除</a-button>  
                </a-col>
                <a-col :span="4">
                  <a-button type="link" icon="user" size="large">授权</a-button>  
                </a-col> -->
              </a-row>
            </a-col>
            <a-table
              rowKey="id"
              :columns="columns"
              :data-source="tableDataSource"
              size="middle"
              :customRow="customRow"
              :pagination="pagination"
              @change="handleTableChange"
              :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}">
              <template slot="value" slot-scope="text, record, index">
                <editable-cell :text="text" @change="onCellChange(record, 'value', $event)" :ref="'editableCellRef' + index" />
              </template>
              <span slot="date" slot-scope="text, record">{{ record.date? (moment(Number(record.date)).format("YYYY-MM-DD HH:mm:ss")):'' }}</span>
              <span slot="type" slot-scope="text">{{ types[text] }}</span>
              <span slot="downCount" slot-scope="text, record">{{ record.type == 'folder'?'' : text }}</span>
              <span slot="readCount" slot-scope="text, record">{{ record.type == 'folder'?'' : text }}</span>
              <span slot="size" slot-scope="text, record">{{ record.type == 'folder'?'' : judgeSize(text) }}</span>
            </a-table>
          </a-row>
      </a-card>
      </a-col>
    </a-row>
    <create-directory ref="createDirectoryRef" @createOk="createOk"></create-directory>
    <authorize ref="authorizeRef"></authorize>
    <view-log-modal-list ref="viewLogModalRef"></view-log-modal-list>
    <j-proview :previewImg="previewImg"></j-proview>
    <UploadFiles :target="selectedValue" action="upload" @success="uploadSuccess" ref="uploadFilesRef"></UploadFiles>
  </div>
</template>
<script>
import Contextmenu from '@/components/menu/Contextmenu'
import CreateDirectory from './modules/CreateDirectory' // 创建目录
import Authorize from './modules/Authorize' // 授权
import UploadFiles from './modules/UploadFiles' // 上传
import EditableCell from './modules/EditableCell' // table列表页编辑
import jProview from '@/components/jeecg/jProview'
import ViewLogModalList from './modules/ViewLogModalList' // 查看日志
import { getAction, postAction, putAction, getFileAccessHttpUrl } from '@/api/manage'
import moment from 'moment';
import { result } from 'lodash';
import { axios } from '@/utils/request'
import Vue from 'vue'
import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types'
const columns = [
  {
    title: '文件名',
    dataIndex: 'value',
    align: 'left',
    width: '30%',
    key: 'value',
    scopedSlots: { customRender: 'value' },
  },
  {
    title: '上传日期',
    dataIndex: 'date',
    align: 'left',
    key: 'date',
    scopedSlots: { customRender: 'date' },
  },
  {
    title: '下载次数',
    dataIndex: 'downCount',
    key: 'downCount',
    align: 'left',
    ellipsis: true,
    scopedSlots: { customRender: 'downCount' },
  },
  {
    title: '阅读次数',
    dataIndex: 'readCount',
    key: 'readCount',
    align: 'left',
    ellipsis: true,
    scopedSlots: { customRender: 'readCount' },
  },
  {
    title: '类型',
    dataIndex: 'type',
    key: 'type',
    align: 'left',
    scopedSlots: { customRender: 'type' },
    ellipsis: true,
  },
  {
    title: '大小',
    dataIndex: 'size',
    key: 'size',
    align: 'right',
    ellipsis: true,
    scopedSlots: { customRender: 'size' },
  },
];
export default {
  name: 'EoaFileManage',
  components: {
    Contextmenu,
    CreateDirectory,
    Authorize,
    UploadFiles,
    EditableCell,
    jProview,
    ViewLogModalList
  },
  data() {
    return {
      downLoadLoading: false, // 下载按钮loading
      keyWord: '', // 搜索关键字
      pagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30', '50', '100'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      previewImg: {
        imgList: [], // 所有图片数组
        index: 0, // 当前点击的图片的索引
        infinite: true, // 是否可以循环切换
        popup: false // 弹窗的显示隐藏
      },
      types: {
        folder: "文件夹", doc: "文档", excel: "表格", pdf: "PDF", pp: "演示文稿", text: "文本", video: "视频", image: "图片",
        code: "文件", audio: "音频", archive: "文档", file: "文件"
      },
      breadcrumbList: [], // 面包屑
      moment,
      treeDataSource: [], // 树形列表数据
      selectedKeys: [], // 选中的数据
      expandedKeys: [], // 树id
      selectedValue: '', // 选中的值
      selectedValueName: '', // 选中的value值
      dataSource: [], // 列表数据
      columns,
      /* table选中keys */
      selectedRowKeys: [],
      /* table选中records */
      selectionRows: [],
      menuVisible: false,
      menuItemList: [
        { key: '1', icon: 'user', text: '授 权' },
        { key: '2', icon: 'folder-add', text: '创建目录' },
        { key: '3', icon: 'folder-add', text: '创建根目录' },
        { key: '4', icon: 'delete', text: '删 除' },
        { key: '5', icon: 'edit', text: '修 改' },
        { key: '6', icon: 'upload', text: '上 传' },
      ],
      url: {
        list: '/api/erp/oa/fileManager/list'
      },
      loading: false
    }
  },
  created () {
    this.loadDataTree()
  },
  computed: {
    tableDataSource () {
      if (!this.keyWord) {
        return this.dataSource
      } else {
        // 根据字模糊搜索
        return this.dataSource.filter(item => {
          return item.value.indexOf(this.keyWord) !== -1
        })
      }
    }
  },
  methods: {
    // 修改表格名称
    onCellChange(record, dataIndex, value) {
      var url = ''
      var params = ''
      url = '/api/erp/oa/fileManager/rename'
        params = `source=${record.id}&action=rename&target=${encodeURIComponent(value)}`
      postAction(url, params).then(res => {
        if (res.success) {
          this.$message.success(res.message)
          // this.$emit('createOk')
          this.loadDataTree()
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    // table 双击下载，右击出现选择框
    customRow(record, index) {
      return {
        on: {
          // 双击下载
          // dblclick: event => {
          //   this.handleDbDownLoad(record, index)
          // },
          // 右击选择
          contextmenu: (event) => {
            event.preventDefault();
            this.selectedRowKeys = [index];
            this.selectionRows = [record];
            this.onContextmenu(record, record.type, 'table')
          },
        }
      }
    },
    // table双击下载
    handleDbDownLoad (record, index) {
      let _this = this
      this.selectedRowKeys = [index];
      this.selectionRows = [record];
      this.$confirm({
        title: '是否下载',
        content: '是否下载该文件夹/文件?',
        okText: '是',
        cancelText: '否',
        onOk() {
          _this.handleDownLoad()
        },
        onCancel() {
        },
      });
    },
    // 获取tree
    async loadDataTree () {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      let res = await getAction(this.url.list)
      this.loading = false;
      if (res.success) {
        /* table选中keys */
        this.selectedRowKeys = []
        /* table选中records */
        this.selectionRows = []
        this.dataSource = []
        this.downLoadLoading = false
        if (res.result.length > 0) {
          this.expandedKeys = []
          // res.result.forEach((item, index) => {
          //   // if (index === 0) {
          //   //   this.selectedKeys = [item.id]
          //   //   this.selectedValue = item.id
          //   // }
            
          // })
          // 这里需要对树形数据进行处理，因为树形是不能展示文件的，只能展示文件夹
          this.treeArrList(res.result)
        }
        this.treeDataSource = res.result
      }
    },
    treeArrList (data) {
      for (let i = 0; i<data.length; i++) {
        
        if (data[i].isFolder != '1') {
          data[i]['style'] = 'display: none'
        } else {
          this.expandedKeys.push( data[i].id)
        }
        // 判断是否有相等的id值
        if (data[i].id == this.selectedKeys[0]) {
          // 当有的时候则判断该下面是否有数据
          if (data[i].data && data[i].data.length) {
            // 有数据则table展示
            this.dataSource = data[i].data
          }
        }
        if (data[i].data && data[i].data.length) {
          this.treeArrList(data[i].data)
        }
      }
      return data
    },
    onContextmenu(e, type, clickType) {
      if (clickType == 'tree') {
        this.loadData([e.node.dataRef.id], e.node)
      }
      if (clickType == 'tree') {
        this.menuItemList = [
          { key: '1', icon: 'user', text: '授 权' },
          { key: '2', icon: 'folder-add', text: '创建目录' },
          // { key: '3', icon: 'folder-add', text: '创建根目录' },
          { key: '4', icon: 'delete', text: '删 除' },
          { key: '5', icon: 'edit', text: '更 名' },
          { key: '6', icon: 'upload', text: '上传' },
        ]
      } else {
        if(type == 'folder') {
          this.menuItemList = [
            { key: '12', icon: 'user', text: '授 权' },
            { key: '13', icon: 'folder-add', text: '创建目录' },
            // { key: '3', icon: 'folder-add', text: '创建根目录' },
            { key: '14', icon: 'delete', text: '删 除' },
            { key: '11', icon: 'edit', text: '更 名' },
            { key: '10', icon: 'upload', text: '上 传' },
            { key: '9', icon: 'download', text: '下 载' },
          ]
        } else {
          this.menuItemList = [
            { key: '7', icon: 'search', text: '预 览' },
            { key: '12', icon: 'user', text: '授 权' },
            { key: '8', icon: 'monitor', text: '查看日志' },
            // { key: '13', icon: 'folder-add', text: '创建目录' },
            // { key: '3', icon: 'folder-add', text: '创建根目录' },
            { key: '14', icon: 'delete', text: '删 除' },
            { key: '11', icon: 'edit', text: '更 名' },
            // { key: '10', icon: 'upload', text: '上传' },
            { key: '9', icon: 'download', text: '下 载' },
          ]
        }
        
      }
      this.menuVisible = true
    },
    onMenuSelect(key, target) {
      switch (key) {
        case '1':
          this.handleAuthorize('tree') // tree授权
          break
        case '2':
          this.handleCreate('create', 'tree') // tree创建目录
          break
        case '3':
          this.handleRootCreate('create') // 创建根目录
          break
        case '4':
          this.handleDelete('remove', 'tree') // 删除
          break
        case '5':
          this.handleEdit() // 更名
          break
        case '6':
          this.handleUpload('tree') // 上传
          break
        case '7':
          this.handlePreView() // 预览
          break
        case '8':
          this.handleViewLog() // 查看日志
          break
        case '9':
          this.handleDownLoad() // 下载
          break
        case '10':
          this.handleUpload('table') // table上传
          break
        case '11':
          this.handleTableEdit('table') // table更名
          break
        case '12':
          this.handleAuthorize('table') // table授权
          break
        case '13':
          this.handleCreate('create', 'table') // table创建目录
          break
        case '14':
          this.handleDelete('remove', 'table') // table创建目录
          break
        default:
          break
      }
    },
    // 点击授权
    handleAuthorize (type) {
      // 判断上传的是哪个id值
      var targetId = ''
      // 先判断是什么类型上传
      if (type == 'tree') {
        // 树上传
        targetId = this.selectedValue // tree的id
      } else 
      {
        targetId = this.selectionRows[0].id
      }
      // 先获取是否有数据
      var url = '/api/erp/oa/fileManager/initAuth?id=' + targetId
      putAction(url).then(res => {
        if (res.success) {
          // 获取数据
          // this.$refs.authorizeRef.visible = true
          res.result.id = targetId // tree选中的id值
          this.$refs.authorizeRef.edit(res.result)
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    // 点击树节点触发
    handleTreeSelect(selectedKeys, info ) {
      let node = info.node
      this.loadData(selectedKeys, node)
      var breadcrumbList = [] // 面包屑
      var temFuc = (arr, selectValue)=>{
        for(let i=0;i<arr.length;i++){
          var selectParent = '' // 
          if (arr[i].id == selectValue) {
            // 当匹配上时知道则往里面塞值且继续往上找
            breadcrumbList.unshift(arr[i])
            if (arr[i].pid) {
              temFuc(this.treeDataSource, arr[i].pid)
            }
            return
          } else {
            // 没有匹配上
            if (arr[i].data && arr[i].data.length) {
              temFuc(arr[i].data, selectValue)
            }
          }
        }
      }
      temFuc(this.treeDataSource, selectedKeys[0])
      this.breadcrumbList = breadcrumbList
    },
    // 点击面包屑
    handleBread (item, index) {
      // 判断一下当点击的时候则会消失后面一个
      this.breadcrumbList = this.breadcrumbList.splice(0, index+1)
      var node = {
        dataRef: item
      }
      this.loadData([item.id], node)
    },
    // 展开/收起节点时触发
    handleTreeExpand (expandedKeys, {expanded: bool, node}) {
      if (bool) {
        if (node && node.dataRef && node.dataRef.data && node.dataRef.data.length) {
          node.dataRef.data.map(value => {
            if (value.isFolder != '1') {
              value['style'] = 'display: none'
            }
          })
        }
      }
    },
    loadData (selectedKeys, node) {
      /* table选中keys */
      this.selectedRowKeys = []
      /* table选中records */
      this.selectionRows = []
      this.downLoadLoading = false
      if (selectedKeys.length > 0) {
        this.selectedKeys = [selectedKeys[0]]
        // 判断是否为目录结构
        if (node.dataRef && node.dataRef.type && node.dataRef.type == 'folder') {
          this.selectedValue = selectedKeys[0]
          this.selectedValueName = node.dataRef.value
        } else {
          this.selectedValue = ''
          this.selectedValueName = ''
        }
        if (node.dataRef && node.dataRef.data && node.dataRef.data.length) {
          this.dataSource = node.dataRef.data
        } else {
          this.dataSource = []
          this.onClearSelected()
        }
        
        // let orgCode = event.node.dataRef.orgCode
        // this.emitInput(orgCode)
      } else {
        this.selectedKeys = []
        this.selectedValue = ''
        this.selectedValueName = ''
        this.dataSource = []
        this.onClearSelected()
      }
    },

    // 点击创建根目录
    handleRootCreate (action) {
      this.$refs.createDirectoryRef.edit()
      this.$nextTick(() => {
        this.$refs.createDirectoryRef.action = action
        this.$refs.createDirectoryRef.target = ''
      })
    },
    // 点击创建子目录，修改名称
    handleCreate (action, type) {
      // 判断上传的是哪个id值
      var targetId = ''
      // 先判断是什么类型上传
      if (type == 'tree') {
        // 树上传
        targetId = this.selectedValue // tree的id
      } else {
        if (this.selectionRows[0].isFolder =='1' ) {
          targetId = this.selectionRows[0].id
        } else {
          targetId = this.selectionRows[0].pid
        }
      }
      this.$refs.createDirectoryRef.edit()
      this.$nextTick(() => {
        this.$refs.createDirectoryRef.action = action
        this.$refs.createDirectoryRef.target = targetId
      })
    },
    // 修改名称
    handleEdit () {
      if (!this.selectedValue) {
        this.$message.warning('请选择目录')
        return
      }
      this.$refs.createDirectoryRef.edit()
      this.$nextTick(() => {
        this.$refs.createDirectoryRef.action = 'rename'
        this.$refs.createDirectoryRef.model.source = this.selectedValueName
        this.$refs.createDirectoryRef.target = this.selectedValue
      })
    },
    // table修改名称
    handleTableEdit () {
      let ref = 'editableCellRef' + this.selectedRowKeys[0]
      this.$refs[ref].edit()
    },
    // 上传
    handleUpload (type) {
      // 判断上传的是哪个id值
      var targetId = ''
      // 先判断是什么类型上传
      if (type == 'tree') {
        // 树上传
        targetId = this.selectedValue // tree的id
      } else 
      {
        targetId = this.selectionRows[0].id
      }
      this.$refs.uploadFilesRef.triggerUpload(targetId)
    },
    uploadSuccess () {
      this.loadDataTree()
    },
    handleDelete (action, type) {
      let _this = this
      // 判断上传的是哪个id值
      var targetId = ''
      // 先判断是什么类型上传
      if (type == 'tree') {
        // 树上传
        targetId = this.selectedValue // tree的id
      } else {
        targetId = this.selectionRows[0].id
      }
      var params = `source=${targetId}&action=${action}`
      this.$confirm({
        title: '确认删除',
        content: '确认删除么？?',
        okText: '确认',
        cancelText: '取消',
        onOk() {
          let url= '/api/erp/oa/fileManager/remove'
          
          postAction(url, params).then(res => {
            if (res.success) {
              _this.$message.success(res.message)
              _this.loadDataTree()
            } else {
              _this.$message.warning(res.message)
            }
          })
        },
        onCancel() {
        },
      });
    },
    // 预览
    handlePreView () {
      // return
      var fileName = this.selectionRows[0].value
      var typeName = this.selectionRows[0].value.split('.')[ this.selectionRows[0].value.split('.').length - 1]
      // var imgArr = ['gif', 'jpg', 'png', 'bmp', 'jpeg', 'webp']
      // 判断是否附件类型
      var url = `/api/erp/oa/fileManager/preview?id=${this.selectionRows[0].id}`
      getAction(url).then(res => {
        if (res.success) {
          let data = res.result;
          if (data.contentType.indexOf('image') !== -1) {
          //  当是图片的时候
          var url = window._CONFIG['domianURL'] + '/api/erp/oa/fileManager/previewFile?id='+ this.selectionRows[0].id + '&token=' +  Vue.ls.get(ACCESS_TOKEN)
          this.previewImg = {
            imgList: [url], // 所有图片数组
            index: 0, // 当前点击的图片的索引
            infinite: true, // 是否可以循环切换
            popup: true // 弹窗的显示隐藏
          }
          } else {
            // 当不是图片的时候
            var fileUrl = getFileAccessHttpUrl(res.result.url)
            let Base64 = require('js-base64').Base64
            window.open(window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(Base64.encode(fileUrl)))
          }
        }
      })
    },
    // 查看日志
    handleViewLog () {
      this.$refs.viewLogModalRef.add(this.selectionRows[0].id)
    },
    // 压缩包下载
    downloadZip () {
      let ids =  this.selectionRows.map((item) => {
        return item.id
      }).join(',')
      let params = {
        zipName: '文档压缩包.zip',
        ids: ids
      }
      let url = window.sessionStorage.getItem('baseUrl') + '/api/erp/oa/fileManager/downloadZip'
      axios({
        url: url,
        params: params,
        method: 'get',
        responseType: 'blob',
        headers:{ 'Content-Type': 'application/json; application/octet-stream'},
      }).then((data) => {
        if (!data || data.size === 0) {
          this.$message.error({content:'下载失败，请重新上传',key: 'downHide'})
          return
        }
        let name = '文档压缩包.zip'
        let blob = new Blob([data], {type: 'application/zip'})
        let url = window.URL.createObjectURL(blob)
        let link = document.createElement('a')
        link.style.display = 'none'
        link.href = url
        link.setAttribute('download', '文档压缩包.zip')
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link) //下载完成移除元素
        window.URL.revokeObjectURL(url) //释放掉blob对象
        this.$message.success({content:'下载成功',key: 'downHide'})
      }).catch(() => {
        this.$message.warning({content:'服务器暂无响应，请稍后再尝试',key: 'downHide'})
      }).finally(() => {
        this.downLoadLoading = false
      })
    },
    // 点击下载文件
    handleDownLoad () {
      if (this.selectionRows && this.selectionRows.length) {
        if (this.downLoadLoading) {
          return
        }
        this.$message.loading({content:'正在下载中...',key: 'downHide', duration: 0}); 
        this.downLoadLoading = true
        // 判断是否是选择了单个
        if (this.selectionRows.length == 1) {
          // 判断是否为文件夹
          if (this.selectionRows[0].type == 'folder') {
            // 当是文件夹的时候就调用另一个接口
            this.downloadZip()
          } else {
            // 当是文件的时候
            let params = `source=${this.selectionRows[0].id}&action=download`
            // downloadFile('/api/erp/oa/fileManager/download', this.selectionRows[0].value, params)
            let url = window.sessionStorage.getItem('baseUrl') + '/api/erp/oa/fileManager/download?' + params
            axios({
              url: url,
              params: {},
              method: 'post',
              responseType: 'blob',
            }).then((data) => {
              if (!data || data.size === 0) {
                this.$message.error({content:'下载失败，请重新上传',key: 'downHide'})
                return
              }
              if (typeof window.navigator.msSaveBlob !== 'undefined') {
                window.navigator.msSaveBlob(new Blob([data]), this.selectionRows[0].value)
              } else {
                let url = window.URL.createObjectURL(new Blob([data]))
                let link = document.createElement('a')
                link.style.display = 'none'
                link.href = url
                link.setAttribute('download', this.selectionRows[0].value)
                document.body.appendChild(link)
                link.click()
                document.body.removeChild(link) //下载完成移除元素
                window.URL.revokeObjectURL(url) //释放掉blob对象
              }
              this.$message.success({content:'下载成功',key: 'downHide'})
            }).catch(() => {
              this.$message.warning({content:'服务器暂无响应，请稍后再尝试',key: 'downHide'})
            }).finally(() => {
              this.downLoadLoading = false
            })
          }
        } else {
          // 当是多个的时候就调用另一个接口
          this.downloadZip()
        }
      } else {
        this.$message.warning('请选择下载内容！')
      }
    },
    
    // table选择的数据
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    // 分页切换
    handleTableChange(pagination, filters, sorter) {
      this.pagination = pagination
    },
    // 清空table选择的数据
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
    },
    // 创建根目录成功
    createOk () {
      this.loadDataTree()
    },
    // 計算文件大小
    judgeSize (size) {
      size = Number(size)
      var fileSize = 0
      // 判断文件的大小
      if (size >= 1024) {
        // 文件大于字节
        if (size / 1024 >=1024) {
          // 文件大于kb
          if (size / 1048576 >=1024) {
            // 文件大于mb
            fileSize = ((size / 1073741824).toFixed(2)) + 'GB'
          } else {
            // 文件小于1024mb
            fileSize = ((size / 1048576).toFixed(2)) + 'MB'
          }
        } else {
          // 文件小于1024kb
          fileSize = ((size / 1024).toFixed(2)) + 'KB'
        }
      } else {
        // 文件小于1024字节
        fileSize = ((size / 1024).toFixed(2)) + 'KB'
      }
      return fileSize
    }
  },
};
</script>
<style lang="less" scoped>
/deep/ .ant-tree-node-content-wrapper {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
</style>